/**      
 * @file		intPointers.cpp 
 * @description		This sample demonstrates integer pointers.
 *			Show the use of * (dereferencing) operator
 *			and the address of & operator.
 * @course		CSCI 123 Section 00000
 * @assignment 
 * @date		mm/dd/yyyy
 * @author		Brad Rippe (00000000) brippe@fullcoll.edu
 * @version		1.0
 */
#include <iostream>
using namespace std;

/**
 * @return zero if the application executes successfully
 */
int main() {
	/* 
	operator is known as the dereferencing operator
	this operator gives the value of the variable a pointer
	points to.
	*/	
	int variable1 = 234;
	int variable2 = 3;

	// declared pointers
	// pointers point to memory addresses
	int *pointer1;
	int *pointer2;

	// & operator give the address of a variable
	pointer1 = &variable1;
	cout << "pointer1 = &variable1;\n";
	// now pointer1 points to the address of variable1
	cout << "pointer1 is pointing to location " << pointer1 
	     << " in hexadecimal." << endl;
	cout << "The value of pointer1 is " << *pointer1 << endl << endl;

	// & operator give the address of a variable
	pointer2 = &variable2;
	cout << "pointer2 = &variable2;\n";
	// now pointer1 points to the address of variable1
	cout << "pointer2 is pointing to location " << pointer2 
	     << " in hexadecimal." << endl;
	cout << "The value of pointer2 is " << *pointer2 << endl << endl;

	// change the location of pointer2 to point to variable1
	// instead of variable2
	pointer2 = pointer1;
	cout << "pointer2 = pointer1;\n";
	cout << "pointer2 is pointing to location " << pointer2 
	     << " in hexadecimal." << endl;
	cout << "The value of pointer2 is " << *pointer2 << endl << endl;

	cout << "Changing the value of pointer1, pointer2, and variable1 to " 
	     << "variable2.\n";

	*pointer2 = variable2;
	cout << "*pointer2 = variable2;\n"; 
	cout << "The value of pointer2 is " << *pointer2 << endl << endl;
	return 0;
}
